package com.fmsz.xmly.adapters;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import com.fmsz.xmly.entitys.FindTabEntity;
import com.fmsz.xmly.fragments.FindFragment;
import com.fmsz.xmly.fragments.findfgts.FindRecommendFragment;

import java.io.Serializable;
import java.util.List;

public class FindVPAdapter extends FragmentPagerAdapter {
    private List<FindTabEntity> list;
    private Fragment[] findFgtArr;
    private FindFragment ff;
    public FindVPAdapter(FragmentManager fm, List<FindTabEntity> list, Fragment[] findFgtArr,FindFragment ff) {
        super(fm);
        this.list = list;
        this.findFgtArr = findFgtArr;
        this.ff=ff;
    }

    @Override
    public Fragment getItem(int position) {
        if (position==0){
            Bundle bundle=new Bundle();
            bundle.putSerializable("data", ff);
            ((FindRecommendFragment)findFgtArr[0]).getInstance(bundle);
        }
        return findFgtArr[position];
    }

    @Override
    public int getCount() {
        return findFgtArr.length;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return list.get(position).getTitle();
    }
}
